#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package}.${artifactId};

import ${package}.${artifactId}.dto.KnowledgeDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(value = "WEBANK", url = "https://api.ownthink.com/", fallback = OwnthinkClient.ProductClientFallback.class)
public interface OwnthinkClient {


    @RequestMapping(value = "/kg/ambiguous?mention={productName}", method = RequestMethod.GET,
            produces = {"text/json;charset=UTF-8"}, headers = "content-type=text/*")
    KnowledgeDTO queryProductName(@RequestParam("productName") String productName);


    /**
     * 回滚事件,需要实现要回滚的对象接口,该回滚是被调用方要执行的业务逻辑.
     */
    @Component
    class ProductClientFallback implements OwnthinkClient {
        private final Logger logger = LoggerFactory.getLogger(ProductClientFallback.class);

        @Override
        public KnowledgeDTO queryProductName(String productName) {

            logger.error("知识图谱暂时不可用");
            return null;
        }
    }
}
